package com.lkxicy.wos.controller;


import com.lkxicy.wos.pojo.entity.SalaryReword;
import com.lkxicy.wos.service.SalaryPaymentService;
import com.lkxicy.wos.service.SalaryRewordService;
import com.lkxicy.wos.utils.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lkxicy
 * @since 2020-11-30
 */
@RestController
@RequestMapping("/wos/v1/salaryReword")
public class SalaryRewordController {

    @Autowired
    private SalaryRewordService salaryRewordService;

    /**
     * 个人奖惩工资
     * @return
     */
    @PostMapping("changeSalary")
    public Response changeSalary(@RequestParam("staffNumber") String staffNumber,
                                 @RequestParam("details") String details,
                                 @RequestParam("salaryChange") double salaryChange,
                                 @RequestParam("beginTime") Date beginTime,
                                 @RequestParam("endTime") Date endTime){
        return Response.success(salaryRewordService.addChangeSalaryRecord(staffNumber, details, salaryChange, beginTime, endTime));
    }

    @PostMapping("changeAllSalary")
    public Response changeAllSalary(@RequestParam("details") String details,
                                    @RequestParam("salaryChange") double salaryChange,
                                    @RequestParam("beginTime") Date beginTime,
                                    @RequestParam("endTime") Date endTime){
        return Response.success(salaryRewordService.addAllChangeSalaryRecord(details, salaryChange, beginTime, endTime));
    }

    /**
     * 查询某个人的全部奖惩记录
     * @return
     */
    @GetMapping("searchOneReword")
    public Response searchOneReword(@RequestParam("staffNumber") String staffNumber){
        return Response.success(salaryRewordService.findOneAllReword(staffNumber));
    }


}

